@extends('admin.layout.base')
@section('title', '修改系统配置项')
@section('content')
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            修改系统配置项
        </h1>
        <ol class="breadcrumb">
            <li><a href="{{ url('/admin') }}"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="{{ url('/admin/system') }}">网站配置</a></li>
            <li class="active">修改配置</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <!-- right column -->
            <div class="col-md-12">
                <!-- Horizontal Form -->
                <div class="box box-info">
                    <div class="box-header with-border">
                        <h3 class="box-title">修改配置</h3>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <form class="form-horizontal" action="{{ url('/admin/system', ['id'=>$data->id]) }}" method="post">
                        {!! csrf_field() !!}
                        {{ method_field('PUT') }}
                        <div class="box-body">
                            <div class="form-group">
                                <label for="config_name" class="col-sm-2 control-label">配置项名称</label>
                                <div class="col-sm-5">
                                    <input type="text" class="form-control" id="config_name" name="title" value="{{ $data->title }}">
                                </div>
                                <div class="col-sm-3 text-danger">{!! $errors->first('title') !!}</div>
                            </div>
                            <div class="form-group">
                                <label for="pid" class="col-sm-2 control-label">所属分类</label>
                                <div class="col-sm-3">
                                    <select name="pid" id="pid" class="form-control">
                                        @foreach($cates as $k=>$v)
                                        <option value="{{ $k }}" {{ $k==$data->pid ? 'selected' : '' }}>{{ $v }}</option>
                                        @endforeach
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="key" class="col-sm-2 control-label">变量名</label>
                                <div class="col-sm-5">
                                    <input type="text" class="form-control" id="key" name="key" value="{{ $data->key }}">
                                </div>
                                <div class="col-sm-3 text-danger">{!! $errors->first('key') !!}</div>
                            </div>
                            <div class="form-group">
                                <label for="type" class="col-sm-2 control-label">配置类型</label>
                                <div class="col-sm-5 radio">
                                    <label>
                                        <input type="radio" name="type" value="string" {{ $data->type == 'string' ? 'checked' : '' }}/>单行文本
                                    </label>
                                    <label>
                                        <input type="radio" name="type" value="radio" {{ $data->type == 'radio' ? 'checked' : '' }}/>单选
                                    </label>
                                    <label>
                                        <input type="radio" name="type" value="textarea" {{ $data->type == 'textarea' ? 'checked' : '' }}/>多行文本
                                    </label>
                                </div>
                            </div>
                            <div class="form-group" id="range" style="{{ $data->type !== 'raido' ? 'display:none;' : ''}}">
                                <label for="value_range" class="col-sm-2 control-label">值范围</label>
                                <div class="col-sm-5">
                                    <input type="text" name="value_range" id="value_range" value="{{ $data->value_range }}" class="form-control"/>
                                </div>
                                <p class="form-control-static text-warning">单选类型为：0开启,1关闭</p>
                            </div>
                            <div class="form-group">
                                <label for="value" class="col-sm-2 control-label">配置项值</label>
                                <div class="col-sm-5">
                                    <textarea name="value" id="value" class="form-control" rows="3">{{ $data->value }}</textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="sort" class="col-sm-2 control-label">排序</label>
                                <div class="col-sm-1">
                                    <input type="text" name="sort" id="sort" value="{{ $data->sort }}" class="form-control"/>
                                </div>
                                <div class="col-sm-7">{!! $errors->first('sort') !!}</div>
                            </div>
                            <div class="form-group">
                                <label for="tip" class="col-sm-2 control-label">备注</label>
                                <div class="col-sm-5">
                                    <input type="text" name="tip" id="tip" value="{{ $data->tip }}" class="form-control"/>
                                </div>
                                <div class="text-danger">{!! $errors->first('tip') !!}</div>
                            </div>
                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <button type="button" class="btn btn-default" onclick="history.go(-1)">返回</button>
                            <button type="submit" class="btn btn-info pull-right">保存</button>
                        </div>
                        <!-- /.box-footer -->
                    </form>
                </div>
                <!-- /.box -->
            </div>
            <!--/.col (right) -->
        </div>
        <!-- /.row -->
    </section>
    <!-- /.content -->
</div>
@endsection
@section('pluginscript')
<!-- FastClick -->
<script src="{{ asset('/dist/admin/plugins/fastclick/fastclick.js') }}"></script>
<script type="text/javascript">
    $(function(){
        $('.radio input[type=radio]').change(function(){
            if($(this).val() == 'radio'){
                $('#range').show();
            } else {
                $('#range').hide();
            }
        });
    });
</script>
@endsection